/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Control;

import aktor.Pasien;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;

/**
 *
 * @author WIN7
 */
public class Pasien_Servlet extends HttpServlet {

    /**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Pasien pas = new Pasien();
        String id = request.getParameter("ID");
        String nama = request.getParameter("Nama");
        String alamat = request.getParameter("Alamat");
        String notelp = request.getParameter("NoTelp");
        String tempatlahir = request.getParameter("TempatLahir");
        String tgllahir = request.getParameter("tglLahir");
        String BB = request.getParameter("BB");
        String TB = request.getParameter("TB");
        String riwayatkesehatan = request.getParameter("RiwayatKesehatan");
        
        
        int BeratBdn = Integer.parseInt(BB);
        int tinggiBdn = Integer.parseInt(TB);
        
        pas.setID(id);
        pas.setNama(nama);
        pas.setAlamat(alamat);
        pas.setTempatlahir(tempatlahir);
        pas.setTgllahir(tgllahir);
        pas.setNotelp(notelp);
        pas.setBB(BeratBdn);
        pas.setTB(tinggiBdn);
        pas.setRiwayatkesehatan(riwayatkesehatan);
        try {
            pas.insertPasien();
        } catch (SQLException ex) {
            Logger.getLogger(Pasien_Servlet.class.getName()).log(Level.SEVERE, null, ex);
        }
        //System.out.println(nama + alamat + tempatlahir + tgllahir + notelp + BeratBdn+ tinggiBdn + riwayatkesehatan);            
        
        response.sendRedirect("verifikasiPendaftaran.jsp");
    }
    
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.processRequest(req, resp);
    }
    
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.processRequest(req, resp);
    }
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
 * Handles the HTTP
 * <code>GET</code> method.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
/**
 * Handles the HTTP
 * <code>POST</code> method.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
/**
 * Returns a short description of the servlet.
 *
 * @return a String containing servlet description
 */
//    @Override
//        public String getServletInfo() {
//        return "Short description";
//    }// </editor-fold>

